<?php
	class FormHelper{
	   
       /**
       *@return string attribute of Label of Form Widget
       */
	   public function setClass($type){
    	   if($type=="labelEx"){
    	       $class=array(
                    'class'=>'control-label',
                    'for'=>'typeahead',
               );
    	   }elseif($type=="textField"){
    	       $class=array(
                    'class'=>'span6 typeahead',
                    'id'=>'typeahead',
               );
    	   }
           elseif($type=="textFieldDisable"){
    	       $class=array(
                    'class'=>'span6 typeahead',
                    'id'=>'typeahead',
                    'disabled'=>'disabled',
               );
    	   }
           elseif($type=="textArea"){
    	       $class=array(
                    'class'=>'cleditor',
                    'id'=>'textarea2',
                    'rows'=>6,
                    'cols'=>50,
               );
    	   }elseif($type=="submitButton"){
    	       $class=array(
                    'class'=>'btn btn-primary',
               );
    	   }elseif($type=="fileField"){
    	       $class=array(
                    'class'=>'input-file uniform_on',
                    'id'=>'fileInput',
               );
    	   }elseif($type=="textFieldDate"){
    	       $class=array(
                    'class'=>'input-xlarge datepicker',
                    'id'=>'date01',
               );
    	   }elseif($type=="textFieldUneditable"){
    	       $class=array(
                    'class'=>'input-xlarge uneditable-input',
               );
    	   }           
           return $class;
	   } 
       
       /**
       *@return str legel of form
       */
       public function getFormBoxHeader($boxName){
            if($this->action->getId()=="update"){
                echo "Cập nhật ".$boxName;
            }else{
                echo "Thêm mới ".$boxName;
            }
       }
       
       /**
       *@return box icon
       **/
       public function getBoxIcon(){
            echo '<a href="#" class="btn btn-setting btn-round"><i class="icon-cog"></i></a>';
			echo '<a href="#" class="btn btn-minimize btn-round"><i class="icon-chevron-up"></i></a>';
			echo '<a href="#" class="btn btn-close btn-round"><i class="icon-remove"></i></a>';
       }
       
       /**
	 * @return string the url with title
     * convert urlUnicode-->urlNormal
	 */
    public function ConvertTitleToUrl($title){
        $unicode = array(
                'a'=>'á|à|ả|ã|ạ|ă|ắ|ặ|ằ|ẳ|ẵ|â|ấ|ầ|ẩ|ẫ|ậ',
                'd'=>'đ',
                'e'=>'é|è|ẻ|ẽ|ẹ|ê|ế|ề|ể|ễ|ệ',
                'i'=>'í|ì|ỉ|ĩ|ị',
                'o'=>'ó|ò|ỏ|õ|ọ|ô|ố|ồ|ổ|ỗ|ộ|ơ|ớ|ờ|ở|ỡ|ợ',
                'u'=>'ú|ù|ủ|ũ|ụ|ư|ứ|ừ|ử|ữ|ự',
                'y'=>'ý|ỳ|ỷ|ỹ|ỵ',
    			'A'=>'Á|À|Ả|Ã|Ạ|Ă|Ắ|Ặ|Ằ|Ẳ|Ẵ|Â|Ấ|Ầ|Ẩ|Ẫ|Ậ',
                'D'=>'Đ',
                'E'=>'É|È|Ẻ|Ẽ|Ẹ|Ê|Ế|Ề|Ể|Ễ|Ệ',
                'I'=>'Í|Ì|Ỉ|Ĩ|Ị',
                'O'=>'Ó|Ò|Ỏ|Õ|Ọ|Ô|Ố|Ồ|Ổ|Ỗ|Ộ|Ơ|Ớ|Ờ|Ở|Ỡ|Ợ',
                'U'=>'Ú|Ù|Ủ|Ũ|Ụ|Ư|Ứ|Ừ|Ử|Ữ|Ự',
                'Y'=>'Ý|Ỳ|Ỷ|Ỹ|Ỵ',
                '-'=>' |%',
            );
            
       foreach($unicode as $nonUnicode=>$uni){
            $title = preg_replace("/($uni)/i", $nonUnicode, $title);
       }
	   return $title;
    }
    
    /**
	 * Returns the static model of the specified AR class.
	 * Please note that you should have this exact method in all your CActiveRecord descendants!
	 * @param string $className active record class name.
	 * @return Brand the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}
    }
?>